import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { InstallService } from '@services/data.service/index';

@Component({
  selector: 'line-step',
  templateUrl: './line-step.html',
  styleUrls: ['line-step.scss']
})
export class LineComponent implements OnInit {
  @Input() roomInfo;
  @Input() installData;
  @Input() Step;
  @Output() NextNum: EventEmitter<any> = new EventEmitter();
  CodeInfo;
  click = false; // 防止重复点击
  constructor(public modalCtrl: ModalController, private installService: InstallService) {
  }

  // 初始页面显示
  ngOnInit() {
    console.log('接线页面房间信息', this.roomInfo);
    this.Step.state = 1;
    setTimeout(() => {
      this.click = true;
    }, 1500);
  }

  // 切换步骤
  toNext(i) {
    this.click = false;
    this.Step.now = i;
    this.installData.step = 3;
    this.installData.data3 = this.CodeInfo;
    this.installService.saveInstallData(this.installData.areaId, this.installData.meterId, this.installData);
    this.NextNum.emit(this.Step.now);
    setTimeout(() => {
      this.click = true;
    }, 1000);
  }
}
